<?php

namespace app\admin\controller;

use app\BaseController;
use Firebase\JWT\JWT;
use think\facade\Config;
use think\facade\Db;
use think\facade\Request;

class Login extends BaseController
{
    public function login()
    {
        $phone = Request::param('account');
        $pwd = Request::param('password');
        $isAdmin = Request::param('isAdmin');
        $info = Db::name('users')->where(array('phone' => $phone, 'pwd' => $pwd))->find();
        if ($info) {
            $info['menus'] = Db::name('menus')->order('ord ASC')->select();
            $info['token'] = createUserToken($info['id']);
        }
        singleJson($info, '账号或密码错误');
    }

}
